package com.relsell.view.phone;

import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.support.v4.app.TaskStackBuilder;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;

import com.relsell.tmcprototype.MainActivity;
import com.relsell.tmcprototype.R;

public class ContactUs extends Activity
{

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.contact_us);
		setupActionBar(false,false,true,true,true);
	}
	/**
	 * setCustomize actionBar Via this method
	 */
	private void setupActionBar(boolean displayShowTitleEnabled,boolean displayUseLogoEnabled,boolean displayHomeAsUpEnabled,boolean displayShowCustomEnabled,boolean displayShowHomeEnabled) {
		ActionBar actionBar = getActionBar();
	    actionBar.setDisplayShowTitleEnabled(displayShowTitleEnabled); 
	    actionBar.setDisplayUseLogoEnabled(displayUseLogoEnabled);   
	    actionBar.setDisplayHomeAsUpEnabled(displayHomeAsUpEnabled);  
	    actionBar.setDisplayShowCustomEnabled(displayShowCustomEnabled); 
	    actionBar.setDisplayShowHomeEnabled(displayShowHomeEnabled);
	    
	    View customNav = LayoutInflater.from(this).inflate(R.layout.cutomizedactionbar, null); // layout which contains your button.
	    TextView tv=(TextView)customNav.findViewById(R.id.textView1);
	    tv.setText(Html.fromHtml(getString(R.string.actionbar_name))); 
	    actionBar.setCustomView(customNav);
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
	    switch (item.getItemId()) {
	        case android.R.id.home:
	            // This is called when the Home (Up) button is pressed in the action bar.
	            // Create a simple intent that starts the hierarchical parent activity and
	            // use NavUtils in the Support Package to ensure proper handling of Up.
	            Intent upIntent = new Intent(this, MainActivity.class);
	            if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
	                // This activity is not part of the application's task, so create a new task
	                // with a synthesized back stack.
	                TaskStackBuilder.from(this)
	                        // If there are ancestor activities, they should be added here.
	                        .addNextIntent(upIntent)
	                        .startActivities();
	                finish();
	            } else {
	                // This activity is part of the application's task, so simply
	                // navigate up to the hierarchical parent activity.
	                NavUtils.navigateUpTo(this, upIntent);
	            }
	            return true;
	    }
	    return super.onOptionsItemSelected(item);
	}
	
}
